<template>
  <div class="app-container">
    <el-form
      :model="queryParams"
      ref="queryForm"
      size="small"
      :inline="true"
      v-show="showSearch"
    >
      <el-form-item label="起始时间" prop="startTime">
        <el-date-picker
          v-model="queryParams.startTime"
          type="datetime"
          format="yyyy-MM-dd HH:mm:ss"
          placeholder="选择日期时间"
        >
        </el-date-picker>
      </el-form-item>
      <el-form-item label="截止时间" prop="endTime">
        <el-date-picker
          v-model="queryParams.endTime"
          type="datetime"
          format="yyyy-MM-dd HH:mm:ss"
          placeholder="选择日期时间"
        >
        </el-date-picker>
      </el-form-item>
      <el-form-item>
        <el-button
          type="primary"
          icon="el-icon-search"
          size="mini"
          @click="handleQuery"
          >查询</el-button
        >
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery"
          >重置</el-button
        >
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <el-col :span="3">导出检测正负样本</el-col>
      <el-col :span="1.5">
        <el-button type="primary" plain size="mini" @click="handleExport"
          >样本导出</el-button
        >
      </el-col>
      <right-toolbar
        :showSearch.sync="showSearch"
        @queryTable="getList"
      ></right-toolbar>
    </el-row>
    <el-table v-loading="loading" :data="dataList">
      <el-table-column
        prop="setCode"
        label="样本类型"
        align="center"
      ></el-table-column>
      <el-table-column
        prop="setName"
        label="航迹批号"
        align="center"
      ></el-table-column>
      <el-table-column
        label="帧序号"
        align="center"
        prop="setDesc"
      ></el-table-column>
      <el-table-column
        label="波位号"
        align="center"
        prop="sourceCode"
      ></el-table-column>
      <el-table-column
        prop="setType"
        label="距离单元"
        align="center"
      ></el-table-column>
      <el-table-column
        prop="setType"
        label="方位单元"
        align="center"
      ></el-table-column>
      <el-table-column
        prop="setType"
        label="多普勒单元"
        align="center"
      ></el-table-column>
      <el-table-column
        prop="setType"
        label="航迹点时间"
        align="center"
      ></el-table-column>
    </el-table>
    <!-- <pagination
      v-show="total > 0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    /> -->
  </div>
</template>

<script>
import {
  exportDownLoadSample,
  getDataQueryDateForTable
} from "@/api/service.js";
import moment from "moment";

export default {
  name: "Datasource",
  components: {},
  data() {
    return {
      // 遮罩层
      loading: true,
      // 显示搜索条件
      showSearch: true,
      // 表格树数据
      dataList: [],
      // 重新渲染表格状态
      refreshTable: true,
      // 总条数
      total: 0,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        startTime: moment().subtract(1, "days").format("YYYY-MM-DD HH:mm"),
        endTime: moment(new Date()).format("YYYY-MM-DD HH:mm"),
      },
      sourceCodeDatas: [],
      //弹窗参数
      dialogVisible: false,
      dialogTitle: "",
      dialogOpen: false,
      dialogData: {},
    };
  },
  created() {
    this.getList();
  },
  methods: {
    getList() {
      this.loading = true;
      let data = {
        startTime: moment(this.queryParams.startTime).format(
          "YYYY-MM-DD HH:mm"
        ),
        endTime: moment(this.queryParams.endTime).format("YYYY-MM-DD HH:mm"),
      };
      getDataQueryDateForTable(data).then((response) => {
        console.log(156, response)
        this.dataList = response?.data?.sourceCounts;
        this.loading = false;
      });
    },
    /** 转换部门数据结构 */
    normalizer(node) {
      if (node.children && !node.children.length) {
        delete node.children;
      }
      return {
        id: node.deptId,
        label: node.deptName,
        children: node.children,
      };
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    //关闭库相关
    closeDialog() {
      this.dialogVisible = false;
      this.dialogOpen = false;
      this.getList();
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    /** 导出按钮操作 */
    handleExport() {
      let data = {
        startTime: moment(this.queryParams.startTime).format(
          "YYYY-MM-DD HH:mm"
        ),
        endTime: moment(this.queryParams.endTime).format(
          "YYYY-MM-DD HH:mm"
        ),
      };
      exportDownLoadSample(data).then((res) => {});
    },
  },
};
</script>
